.PHONY: clean mrproper

DEBUG  = yes
CC     = gcc
CFLAGS = -D_REENTRANT -W -Wall -Wextra `pkg-config --cflags --libs glib-2.0` -I./src

ifeq ($(DEBUG), yes)
	$(CFLAGS)= -g $(CFLAGS)
endif

CFILES      := $(wildcard src/*.c)
EXESOURCES  := $(wildcard exemples/*.c)
OBJFILES    := $(patsubst %.c, %.o, $(CFILES))
OBJEXE      := $(patsubst %.c, %.o, $(EXESOURCES))
EXEFILES    := $(patsubst exemples/%.c, %, $(EXESOURCES))

all: $(OBJFILES) $(EXEFILES)
ifeq ($(DEBUG), yes)
	@echo "Génération en mode debug"
else
	@echo "Génération en mode release"
endif

%: exemples/%.o $(OBJFILES)
	@echo $(CC) CFLAGS -o $@
	@$(CC) $(CFLAGS) $^ -o $@

%.o: %.c
	@echo $(CC) CFLAGS -c -o $@
	@$(CC) -c $(CFLAGS) $< -o $@

clean:
	@rm -vf $(OBJFILES) *~

mrproper: clean
	@rm -vf $(EXEFILES) *~
